<template>
	<view class="uni_box home">
		<navbar title='我的收益'>
		</navbar>
		<view class="content">
			<view class="syone">
				<view class="smone" @click="iseye=!iseye">
					<text class="msy">我的收益</text>
					<image class="syeye" src="/static/img/syeye.png" v-if="!iseye"></image>
					<image class="syeye" src="/static/img/syeyes.png" v-if="iseye"></image>
				</view>
				<view class="jia">
					<text class="jiafu">¥<text class="jianum"  :class="!iseye?'feieye':''">{{iseye?uinfo.income:'***'||0 }}</text></text>
				</view>
				<view class="ti" @click="tixian">提现</view>
			</view>
			<view class="sytwo">
				<text class="shouzhi">收支明细</text>
				<view class="mxlist">
					<view class="mxitem" v-for="(item,index) in list" :key="index">
						<!-- <view class="mone">
							<image class="tou" src="/static/img/tou.png"></image>
							<view class="mrview">
								<text class="name">福临@Bitidea</text>
								<view class="guanview">
									<text class="gleft">用户ID：{{ item.id }}</text>
									<text class="gleft ml">推荐关系：直接佣金</text>
								</view>
							</view>
						</view> -->
						<view class="mtwo">
							<view class="mtitem">
								<text>金额：{{ item.value }}</text>
							</view>
							<view class="mtitem">
								<text>时间：{{ item.created_at }}</text>
							</view>
							<view class="mtitem">
								<text>类型：{{ item.type_name }}</text>
							</view>
							<view class="mtitem">
								<text>余额：{{item.after}}</text>
							</view>
							
						</view>
					</view>
				</view>
				<u-loadmore :status="status" @loadmore="loadmore" /> 
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				uinfo:{},
				iseye:true
			}
		},
		onLoad() {
			this.getList()
		},
		onShow() {
		},
		onReachBottom: function () {
			this.loadmore();
		},
		methods: {
			async getList(){//列表数据
				let res = await this.$u.api.userlog({
					limit:this.limit,
				  	page:this.page,
					field:'balance'
				});
				// console.log(res)
				this.uinfo = res
				this.last_page = res.list.last_page;
				let list = res.list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];	
				if(this.page >= this.last_page){
				  this.status = 'nomore';
				}
				
			},
			loadmore() {
				let page = this.page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},

			tixian(){
				this.navrouter("/pages/TPage/TiXian");
			},

		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
	}
	.content{
		background-color: #F5F5F5;
		min-height: 100vh;
		padding: 30rpx;
		.syone{
			position: relative;
			background-color: #3861e7;
			padding: 40rpx 30rpx;
			border-radius: 25rpx;
			display: flex;
			flex-direction: column;
			.smone{
				display: flex;
				flex-direction: row;
				align-items: center;
				.syeye{
					margin-left: 20rpx;
					width: 30rpx;
					height: 30rpx;
				}
				.msy{
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #EAE9EF;
				}
			}
		}
		.jia{
			margin-top: 40rpx;
			display: flex;
			flex-direction: row;
			.jiafu{
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #FFFFFF;
			}
			.jianum{
				font-size: 50rpx;
				margin-left: 4rpx;
				display: inline-block;
			}
			.feieye{
				position: relative;
				top: 14rpx;
				margin-left: 4rpx;
			}
		}
		.ti{
			position: absolute;
			right: 40rpx;
			top: 40rpx;
			width: 120rpx;
			height: 62rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			border-radius: 10rpx;
			border: 2rpx solid #FFFFFF;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #FFFFFF;
		}
		.sytwo{
			.shouzhi{
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #171F48;
				display: block;
				margin: 30rpx 0;
			}
			.mxlist{
				.mxitem{
					padding: 30rpx 30rpx 10rpx;
					background: #FFFFFF;
					border-radius: 20rpx;
					margin-bottom: 20rpx;
					.mone{
						display: flex;
						flex-direction: row;
						padding-bottom: 20rpx;
						border-bottom: 1rpx solid #eee;
						.tou{
							margin-right: 20rpx;
							width: 80rpx;
							height: 80rpx;
							border-radius: 50%;
						}
						.mrview{
							display: flex;
							flex-direction: column;
							flex: 1;
							.name{
								font-family: PingFang SC;
								font-weight: bold;
								font-size: 28rpx;
								color: #222222;
							}
							.guanview{
								display: flex;
								flex-direction: row;
								align-items: center;
								margin-top: 10rpx;
								.gleft{
									font-family: PingFang SC;
									font-weight: 400;
									font-size: 24rpx;
									color: #666666;
								}
								.ml{
									margin-left: auto;
								}
							}
						}
					}
					.mtwo{
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						// margin-top: 30rpx;
						.mtitem{
							display: flex;
							flex-direction: row;
							width: 50%;
							margin-bottom: 20rpx;
							text{
								font-family: PingFang SC;
								font-weight: 400;
								font-size: 24rpx;
								color: #666666;
							}
						}
					}
				}
			}
		}
	}
</style>
